﻿using Brc_PaaS.Common.Model.Basic;
using Brc_PaaS.Common.Model.RabbitMq;
using Brc_PaaS.Core.RabbitMq;
using Exceptionless;
using Exceptionless.Logging;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;

namespace Brc_PaaS.Api.Common
{

    /// <summary>
    /// PaaS平台监听消息队列
    /// </summary>
    public class PaaSRabbitMqListener : RabbitMqListener
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="configuration"></param>
        public PaaSRabbitMqListener(IConfiguration configuration) : base(configuration)
        {          
            queueName = "Brc_PaaS_Queue-1";
        }

        /// <summary>
        /// 监听到消息后业务处理
        /// </summary>
        /// <param name="eventMessage"></param>
        /// <returns></returns>
        public override BaseResponseModel Process(EventMessage eventMessage)
        {
            Task.Run(() => {
                ExceptionlessClient.Default.CreateLog($"{eventMessage.MessageMark}消息队列获取", $"PaaS平台监听到业务系统{eventMessage.MessageMark}传入消息队列的消息。消息内容：【{eventMessage.Message}】消息时间：【{eventMessage.MessageCreatedTime}】消息Id【{eventMessage.MessageId}】", LogLevel.Info).Submit();
            });
            
            return base.Process(eventMessage);
        }
    }
}
